import { Application } from 'egg';
const consola = require('consola');

export default (app: Application) => {
  const { router, controller } = app;
  consola.success('env', app.config.env);
  if (app.config.env === 'local' || app.config.env === 'prod') {
    app.beforeStart(async () => {
      await app.model.sync();
    });
  }
  router.get('/', controller.index.home);
  // 公共部分路由
  require('./routes/common_route')(app);
  // 普通用户相关路由
  require('./routes/user_route')(app);
  // 管理员相关路由
  require('./routes/admin_route')(app);
  // 角色相关路由
  require('./routes/role_route')(app);
  // 内容相关路由
  require('./routes/content_route')(app);
  // 爬虫与反爬虫
  require('./routes/crawler_route.js')(app);
  // 分类相关路由
  require('./routes/category_route.js')(app);
  // 前端信息配置路由
  require('./routes/font_config_route.js')(app);
  // 标签路由
  require('./routes/tag_route.js')(app);
  // 前端接口配置
  require('./routes/font_route.js')(app);
  // 系统管理
  require('./routes/system_rotue.js')(app);
  // 验证码相关配置
  require('./routes/invite_code_route.js')(app);
};
